      REAL*8 FUNCTION PRECES50(TSEC50,KEY)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C  THIS ROUTINE COMPUTES THE ANGLE THROUGH WHICH THE MEAN VERNAL EQUINOX
C  HAS PRECESSED FROM THE BEGINNING OF THE BESSELIAN YEAR 1950(1950.0)
C  TO THE CURRENT TIME. THE PRECESSION IN RIGHT ASCENSION AND IN 
C  DECLINATION ARE ALSO AVAILABLE.
C
C  NUTATION HAS NOT BEEN CONSIDERED, SO COORDINATE SYSTEMS ARE 'MEAN'.
C
C  VARIABLE  DIM  TYPE  I/O  DESCRIPTION
C  --------  ---  ----  ---  -----------
C
C  TSEC50     1   R*8    I   TIME AT WHICH THE PRECESSION ANGLE IS
C                            WANTED. IN SECONDS SINCE 1/1/50, AT
C                            0.0 HOURS, ET. NOTE THAT UT MAY BE USED
C                            BECAUSE ACCURACY IS NOT HIGH ENOUGH 
C                            FOR THE TIME DIFFERENCE TO MATTER.
C 
C  KEY        1   I*4    I   INDICATOR OF WHAT IS TO BE COMPUTED.
C                            = 1, PRECES50 IS THE RIGHT ASCENSION, 
C                                 RELATIVE TO THE MEAN OF 1950.0 
C                                 COORDINATE SYSTEM, OF THE X-AXIS OF
C                                 THE MEAN OF DATE COORDINATE SYSTEM.
C                            = 2, PRECES50 IS THE DECLINATION, RELATIVE
C                                 TO THE MEAN OF 1950.0 COORDINATE
C                                 SYSTEM, OF THE X-AXIS OF THE MEAN OF 
C                                 DATE COORDINATE SYSTEM.
C                            = OTHERWISE, PRECES50 IS THE MAGNITUDE OF
C                              THE TOTAL PRECESSION.
C
C  PRECES50   1   R*8    O   THE PRECESSION ANGLE. (RADIANS).
C
C**********************************************************************'
C
C  CODED BY C PETRUZZO, 10/82.
C     MODIFIED.....
C       CJP 6/83. COMPLETE REPLACEMENT OF THE METHOD OF COMPUTING
C                 PRECESSION. CALLING SEQUENCE CHANGE.
C
C**********************************************************************'
C
      INTEGER INIT/1/
      REAL*8 DEGRAD/ 57.29577951308232D0 /
      REAL*8 TLAST/-1.D10/,ROTMTX(3,3),XUNIT(3)
      EQUIVALENCE (XUNIT(1),ROTMTX(1,1))
C
      IF(TSEC50.NE.TLAST) THEN
        TLAST=TSEC50
        CALL M50MDT(TSEC50,-1,ROTMTX)  ! MDT TO M50
        END IF
C
C  THE VECTOR (1,0,0) IN MEAN OF DATE COORDINATES BECOMES THE VECTOR
C  XUNIT WHEN EXPRESSED IN MEAN OF 1950.0 COORDINATES. THEREFORE, THE
C  RACN AND DECL ARE RELATIVE TO THE MEAN OF 1950.0 COORDINATES.
C
      IF(KEY.EQ.1) THEN    ! RACN 
        PRECES50=DATAN2(XUNIT(2),XUNIT(1))
      ELSE IF(KEY.EQ.2) THEN    ! DECL 
        PRECES50=DASIN(XUNIT(3))
      ELSE     ! MAGNITUDE OF TOTAL PRECESSION. 
        PRECES50=DACOS(XUNIT(1))
        END IF
C
      RETURN
      END
